import 'package:flutter/material.dart';

extension StringExtension on String? {
  bool isNotEmptyAndNotNull() {
    final str = this;
    return str != null && str.isNotEmpty;
  }

  Size boundingTextSize(TextStyle style,
      {int maxLines = 2 ^ 31, double maxWidth = double.infinity}) {
    if (this == null || this?.isEmpty == true) {
      return Size.zero;
    }
    final TextPainter textPainter = TextPainter(
        textDirection: TextDirection.ltr,
        text: TextSpan(text: this, style: style),
        maxLines: maxLines)
      ..layout(maxWidth: maxWidth);
    return textPainter.size;
  }
}
